//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "ChValuteForm.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFChVal *FChVal;
//---------------------------------------------------------------------------
__fastcall TFChVal::TFChVal(TComponent* Owner)
        : TForm(Owner)
{
 mX = -100;
 mY = -100;
}
//---------------------------------------------------------------------------
void __fastcall TFChVal::ListBox1Click(TObject *Sender)
{
// Close();
}
//---------------------------------------------------------------------------

void __fastcall TFChVal::ListBox1DrawItem(TWinControl *Control, int Index,
      TRect &Rect, TOwnerDrawState State)
{
 //
 if(( (Rect.left <= mX) && (Rect.right>=mX) &&(Rect.top <= mY) && (Rect.Bottom>=mY)) || (State.Contains(odSelected)))
 {
 TColor C1 = ListBox1->Canvas->Brush->Color;
 TColor C2 = ListBox1->Canvas->Pen->Color;
 ListBox1->Canvas->Brush->Color = clRed;
 ListBox1->Canvas->Pen->Color = clRed;
 ListBox1->Canvas->Rectangle(Rect);
 ListBox1->Canvas->TextOut(Rect.left+2, Rect.top, ((TListBox *)Control)->Items->Strings[Index]);
 ListBox1->Canvas->Brush->Color = C1;
 ListBox1->Canvas->Pen->Color = C2;
 ((TListBox *)Control)->ItemIndex = Index;
 }
 else
 {
  TColor C2 = ListBox1->Canvas->Pen->Color;
  ListBox1->Canvas->Pen->Color = ListBox1->Canvas->Brush->Color;
  ListBox1->Canvas->Rectangle(Rect);
  ListBox1->Canvas->TextOut(Rect.left+2, Rect.top, ((TListBox *)Control)->Items->Strings[Index]);
  ListBox1->Canvas->Pen->Color = C2;
 }
}
//---------------------------------------------------------------------------


void __fastcall TFChVal::ListBox1MouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
// mX = X; mY = Y;
// ListBox1->Invalidate();
}
//---------------------------------------------------------------------------

void __fastcall TFChVal::FormCreate(TObject *Sender)
{
 DoubleBuffered = true;
 Panel1-> DoubleBuffered = true;
 ListBox1-> DoubleBuffered = true;
}
//---------------------------------------------------------------------------

void __fastcall TFChVal::ListBox1KeyPress(TObject *Sender, char &Key)
{
 if(Key == 13)
 {
  Key = 0;
  ModalResult = mrOk;
  //Close();
 }
 if(Key == 27)
 {
  ModalResult = mrCancel;
  ListBox1->ItemIndex = -1;
 }
}
//---------------------------------------------------------------------------

void __fastcall TFChVal::ListBox1MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
 Close();        
}
//---------------------------------------------------------------------------

